﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ObjectDataSource.aspx.cs" Inherits="demo.Pages.ObjectDataSource" %>

<%@ Register Assembly="Water" Namespace="Water.Web.Controls" TagPrefix="page" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <page:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="demo.Objects.BLL.Employees" CanSelect="true" EnablePaging="true" >
        </page:ObjectDataSource>
        <fieldset>
            <legend>ObjectDataSource</legend>
            <ul>
                <li>继承与System.Web.UI.WebControls.ObjectDataSource</li>
                <li>只需将CanSelect、CanInsert、CanUpdate和CanDelete属性设置为true即可实现对查询、插入、更新和删除,而无需指定方法（也可指定）</li>
                <li>和Container控件配合使用可达到事半功倍的效果</li>
            </ul>
        </fieldset>
        <br />
        <page:Container ID="container1" runat="server" Promptable="false" DisplayBorder="true" TitleText="员工基本信息" PackageType="Div">
            <ItemTemplate>
                <page:ListView ID="ListView1" runat="server" DataSourceID="ObjectDataSource1" AutoQuery="true" IsCallBack="true" ShowFooter="true"
                    AutoUpdatedAfterCallBack="true" GridHeight="450px">
                    <Columns>
                        <page:BoundField DataField="id" HeaderStyle-Width="50" HeaderPrompt="employees.id" SortExpression="id" FooterPrompt="Σ：" />
                        <page:BoundField DataField="firstname" HeaderStyle-Width="100" HeaderPrompt="employees.firstname" SortExpression="firstname" />
                        <page:BoundField DataField="lastname" HeaderStyle-Width="100" HeaderPrompt="employees.lastname" SortExpression="lastname" />
                        <page:BoundField DataField="email" HeaderStyle-Width="150" HeaderPrompt="employees.email" />
                        <page:BoundField DataField="hiredate" DataFormatString="{0:yyyy-MM-dd}" ItemStyle-ForeColor="#0000ff" HeaderStyle-Width="80"
                            SortExpression="hiredate" HeaderPrompt="employees.hiredate" />
                        <page:BoundField DataField="salary" HeaderStyle-Width="180" SortExpression="salary" HeaderPrompt="employees.salary" SummaryFunction="Sum"
                            NullDisplayText="0" DataFormatString="{0:C}" ItemStyle-HorizontalAlign="Right" FooterStyle-HorizontalAlign="Right" />
                    </Columns>
                    <PagerTemplate>
                        <page:DataPager ID="DataPager1" runat="server" PageSize="20" PagedControlID="ListView1" AutoUpdatedAfterCallBack="true" QueryTarget="ListView1" />
                    </PagerTemplate>
                </page:ListView>
            </ItemTemplate>
        </page:Container>
    </div>
    </form>
</body>
</html>
